{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "import k3d.platonic as platonic\n",
    "import math\n",
    "import numpy as np\n",
    "\n",
    "def test(plot):\n",
    "    colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff]\n",
    "\n",
    "    for j in range(5):\n",
    "        meshes = [\n",
    "            platonic.Dodecahedron().mesh,\n",
    "            platonic.Cube().mesh,\n",
    "            platonic.Icosahedron().mesh,\n",
    "            platonic.Octahedron().mesh,\n",
    "            platonic.Tetrahedron().mesh\n",
    "        ]\n",
    "\n",
    "        for i, obj in enumerate(meshes):\n",
    "            rad = math.radians(i / len(meshes) * 360)\n",
    "            radius = 3.5\n",
    "            obj.transform.translation = [math.sin(rad) * radius, math.cos(rad) * radius, 2*j]\n",
    "            obj.color = colors[i]\n",
    "            plot += obj\n",
    "\n",
    "    plot.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = k3d.plot()\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.auto_rendering = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test(plot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "while plot.objects:\n",
    "    plot -= plot.objects[-1]\n",
    "\n",
    "plot.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test(plot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.auto_rendering = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "while len(plot.objects) > 2:\n",
    "    plot -= plot.objects[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(10):\n",
    "    plot += k3d.points(np.random.randn(1,3).astype(np.float32))\n",
    "    plot.camera = [-0.9639876204909027,\n",
    "         -23.61169267956684,\n",
    "         i,\n",
    "         0,\n",
    "         0.334220290184021,\n",
    "         4,\n",
    "         0.007512009764659415,\n",
    "         0.3054834418666324,\n",
    "         0.9521677564665881]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "nbTranslate": {
   "displayLangs": [
    "en",
    "pl"
   ],
   "hotkey": "alt-t",
   "langInMainMenu": true,
   "sourceLang": "pl",
   "targetLang": "en",
   "useGoogleTranslate": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
